package DataBase;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import common.Tables.Psychologists;

/**
 * class Queries.
 * for tests only
 * 
 * @author michal
 *
 */
public class Queries {
	public enum Table {
	    USERS,PSYCHOLOGISTS,PSYCHAV,TASKS,CLIENTS
	}
	
	public static void main(String[] args) {
		Table table=Table.PSYCHOLOGISTS;
		SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
		Session session = sessionFactory.openSession();
		switch(table){
		case USERS:
			DBUsers queryUsers = new DBUsers(sessionFactory,session);
			System.out.println("---allUser----");
			queryUsers.getUsers();
			System.out.println("----firstName-----");
			queryUsers.getUsersByFirstName("fName1");
			System.out.println("----ID-----");
			System.out.println(queryUsers.getUsersByID("1"));
			System.out.println("----Permission-----");
			queryUsers.getUsersByPermission("all");
			System.out.println("---FirstLastName------");
			queryUsers.getUsersByFirstLastName("a", "b");
			System.out.println("----LastName-----");
			queryUsers.getUsersByLastName("b");
			break;
		case PSYCHOLOGISTS:
			DBPsychologists queryPsychs = new DBPsychologists(sessionFactory, session);
			System.out.println("----firstName-----");
			queryPsychs.getPsychsByFirstName("fPsych2");
			System.out.println("----ID-----");
			//System.out.println(queryPsychs.getPsychsByID("23"));
			List<common.Tables.Table> ps = queryPsychs.getPsychsByID("23");
			Psychologists p = (Psychologists)(ps.get(0));
			System.out.println(p.getAvailability());
			System.out.println("---FirstLastName------");
			queryPsychs.getPsychsByFirstLastName("fPsych1", "lPsych1");
			break;
		case PSYCHAV:
			DBPsychAvailability queryPsychsAv = new DBPsychAvailability(sessionFactory, session);
			queryPsychsAv.getPsychAvailability();
			System.out.println("-----byID---------");
			System.out.println(queryPsychsAv.getPsychAvailabilityByPsychID("10"));
			System.out.println("-----byFName---------");
			queryPsychsAv.getPsychAvailabilityByPsychFName("moshe");
			break;
		case TASKS:
			DBTasks queryTasks = new DBTasks(sessionFactory,session);
			System.out.println("----allTasks---");
			queryTasks.getTasks();
			System.out.println("----tasks by Id----");
			queryTasks.getTasksByID(2);
			System.out.println("----tasks by Name----");
			queryTasks.getTasksByTaskName("task1");
			System.out.println("----byWeight-----");
			//queryTasks.getTasksByTaskWeight("4");
		case CLIENTS:
			break;
		}
	}
}
